{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>用户权限设置</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <input type="hidden" class="layui-input" value="{$info.user_id}" name="user_id" />
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">用户身份</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">用户身份：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="user_d_type" value="1" title="普通用户" {if $info.user_d_type==1}checked{/if}>
                                <input type="radio" name="user_d_type" value="2" title="设计师" {if $info.user_d_type==2}checked{/if}>
                                <input type="radio" name="user_d_type" value="3" title="商家" {if $info.user_d_type==3}checked{/if}>
                                <input type="radio" name="user_d_type" value="4" title="客户" {if $info.user_d_type==4}checked{/if}>
                                <input type="radio" name="user_d_type" value="5" title="业务员" {if $info.user_d_type==5}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">用户案例权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">用户权限类型：</label>
                            <div class="layui-input-block">
                                <input type="checkbox" value="1" name="user_type[]" title="普通用户" {if in_array(1,$info.user_type)}checked{/if} />
                                <input type="checkbox" value="2" name="user_type[]" title="合作商" {if in_array(2,$info.user_type)}checked{/if} />
                                <input type="checkbox" value="3" name="user_type[]" title="业务员" {if in_array(3,$info.user_type)}checked{/if} />
                                <input type="checkbox" value="4" name="user_type[]" title="内部员工" {if in_array(4,$info.user_type)}checked{/if} />
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">客户上传权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">客户上传：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="user_shangchuan" value="1" title="不可以" {if $info.user_shangchuan==1}checked{/if}>
                                <input type="radio" name="user_shangchuan" value="2" title="可以" {if $info.user_shangchuan==2}checked{/if}>
                            </div>
                        </div>
                        <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
                            <!--<label class="layui-form-label">案例权限：</label>-->
                            <!--<div class="layui-input-block">-->
                                <!--<input type="radio" name="user_my" value="1" title="只能看已完成案例" {if $info.user_my==1}checked{/if}>-->
                                <!--<input type="radio" name="user_my" value="2" title="可以看所有案例" {if $info.user_my==2}checked{/if}>-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">用户电话权限</h5>
                        </div>
                        <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
                            <!--<label class="layui-form-label">门店电话权限：</label>-->
                            <!--<div class="layui-input-block">-->
                                <!--<input type="radio" name="user_phone_auth" value="1" title="不可以看门店电话" {if $info.user_phone_auth==1}checked{/if}>-->
                                <!--<input type="radio" name="user_phone_auth" value="2" title="可以看门店电话" {if $info.user_phone_auth==2}checked{/if}>-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">设计师电话权限：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="user_d_phone_auth" value="1" title="不可以看设计师电话" {if $info.user_d_phone_auth==1}checked{/if}>
                                <input type="radio" name="user_d_phone_auth" value="2" title="可以看设计师电话" {if $info.user_d_phone_auth==2}checked{/if}>
                            </div>
                        </div>
                        <!------------------------------------------>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">订单管理和订单汇总权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">品牌详情里的订单汇总：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="user_see_pp" value="1" title="不可以看" {if $info.user_see_pp==1}checked{/if}>
                                <input type="radio" name="user_see_pp" value="2" title="可以看" {if $info.user_see_pp==2}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">设计师详情里的订单管理：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="user_see_user" value="1" title="不可以看" {if $info.user_see_user==1}checked{/if}>
                                <input type="radio" name="user_see_user" value="2" title="可以看" {if $info.user_see_user==2}checked{/if}>
                            </div>
                        </div>
                        <!------------------------------------------>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">用户查看品牌时的佣金/优惠权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">佣金身份权限：</label>
                            <div class="layui-input-block" style="width: 100%">
                                <input type="radio" name="user_yongjin_auth" value="0" title="普通用户" {if $info.user_yongjin_auth==0}checked{/if}>
                                <input type="radio" name="user_yongjin_auth" value="1" title="设计师" {if $info.user_yongjin_auth==1}checked{/if}>
                                <input type="radio" name="user_yongjin_auth" value="2" title="合作业务" {if $info.user_yongjin_auth==2}checked{/if}>
                                <input type="radio" name="user_yongjin_auth" value="3" title="公司业务" {if $info.user_yongjin_auth==3}checked{/if}>
                                <input type="radio" name="user_yongjin_auth" value="4" title="公司管理层" {if $info.user_yongjin_auth==4}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">优惠身份权限：</label>
                            <div class="layui-input-block" style="width: 100%">
                                <input type="radio" name="user_youhui_auth" value="1" title="普通用户" {if $info.user_youhui_auth==1}checked{/if}>
                                <input type="radio" name="user_youhui_auth" value="2" title="高级用户" {if $info.user_youhui_auth==2}checked{/if}>
                                <input type="radio" name="user_youhui_auth" value="3" title="贵宾用户" {if $info.user_youhui_auth==3}checked{/if}>
                                <input type="radio" name="user_youhui_auth" value="4" title="vip用户" {if $info.user_youhui_auth==4}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">用户查看设计师时的佣金/优惠权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">佣金身份权限：</label>
                            <div class="layui-input-block" style="width: 100%">
                                <input type="radio" name="user_d_yongjin_auth" value="1" title="普通用户" {if $info.user_d_yongjin_auth==1}checked{/if}>
                                <input type="radio" name="user_d_yongjin_auth" value="2" title="业务员" {if $info.user_d_yongjin_auth==2}checked{/if}>
                                <input type="radio" name="user_d_yongjin_auth" value="3" title="高级业务员" {if $info.user_d_yongjin_auth==3}checked{/if}>
                                <input type="radio" name="user_d_yongjin_auth" value="4" title="公司业务员" {if $info.user_d_yongjin_auth==4}checked{/if}>
                                <input type="radio" name="user_d_yongjin_auth" value="5" title="公司管理层" {if $info.user_d_yongjin_auth==5}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">优惠身份权限：</label>
                            <div class="layui-input-block" style="width: 100%">
                                <input type="radio" name="user_d_youhui_auth" value="1" title="普通用户" {if $info.user_d_youhui_auth==1}checked{/if}>
                                <input type="radio" name="user_d_youhui_auth" value="2" title="高级用户" {if $info.user_d_youhui_auth==2}checked{/if}>
                                <input type="radio" name="user_d_youhui_auth" value="3" title="贵宾用户" {if $info.user_d_youhui_auth==3}checked{/if}>
                                <input type="radio" name="user_d_youhui_auth" value="4" title="vip用户" {if $info.user_d_youhui_auth==4}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">能看到的客户</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">范围：</label>
                            <div class="layui-input-block">
                                <select name="user_see_cases_type" lay-filter="role5">
                                    <option value="1" {if $sel3==1} selected {/if}>全部看不到</option>
                                    <option value="2" {if $sel3==2} selected {/if}>所有都可见</option>
                                    <option value="3" {if $sel3==3} selected {/if}>部分可见</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {if $sel3 != 3}hidden{/if}" id="anli">
                            <label class="layui-form-label">案例：</label>
                            <div class="layui-input-block">
                                <select name="user_see_cases" xm-select="select5" xm-select-search="" xm-select-search-type="dl">
                                    <option value="">请选择案例</option>
                                    {foreach name="cases" item="v"}
                                    <option value="{$v.case_id}" {if in_array($v.case_id,$info.user_see_cases)}selected{/if}>{$v.case_name}({$v.case_address})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">能看到的设计师范围权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">范围：</label>
                            <div class="layui-input-block">
                                <select name="user_d_auth_uids_type" lay-filter="role">
                                    <option value="1" {if $sel==1} selected {/if}>全部看不到</option>
                                    <option value="2" {if $sel==2} selected {/if}>所有都可见</option>
                                    <option value="3" {if $sel==3} selected {/if}>部分可见</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {if $sel != 3}hidden{/if}" id="shejishi">
                            <label class="layui-form-label">设计师：</label>
                            <div class="layui-input-block">
                                <select name="user_d_auth_uids" xm-select="select2" xm-select-search="" xm-select-search-type="dl">
                                    <option value="">请选择设计师</option>
                                    {foreach name="users2" item="v"}
                                    <option value="{$v.user_id}" {if in_array($v.user_id,$info.user_d_auth_uids)}selected{/if}>{$v.user_d_name}({$v.user_phone})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">能看到的门店范围权限</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">范围：</label>
                            <div class="layui-input-block">
                                <select name="user_d_auth_sids_type" lay-filter="role2">
                                    <option value="1" {if $sel2==1} selected {/if}>全部看不到</option>
                                    <option value="2" {if $sel2==2} selected {/if}>所有都可见</option>
                                    <option value="3" {if $sel2==3} selected {/if}>部分可见</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 {if $sel2 != 3}hidden{/if}" id="shejishi2">
                            <label class="layui-form-label">门店：</label>
                            <div class="layui-input-block">
                                <div id="demo2" class="xm-select-demo"></div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <h5 style="color: cornflowerblue">个性化主页面推荐</h5>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">设计师：</label>
                            <div class="layui-input-block" style="width: 100%">
                                <select name="user_users" xm-select="select3" xm-select-search="" xm-select-search-type="dl">
                                    <option value="">请选择设计师</option>
                                    {foreach name="users2" item="v"}
                                    <option value="{$v.user_id}" {if in_array($v.user_id,$info.user_users)}selected{/if}>{$v.user_d_name}({$v.user_phone})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">案例：</label>
                            <div class="layui-input-block" style="width: 100%">
                                <select name="user_cases" xm-select="select4" xm-select-search="" xm-select-search-type="dl">
                                    <option value="">请选择案例</option>
                                    {foreach name="cases" item="v"}
                                    <option value="{$v.case_id}" {if in_array($v.case_id,$info.user_cases)}selected{/if}>{$v.case_name}({$v.case_address})</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">品牌：</label>
                            <div class="layui-input-block">
                                <div id="demo1" class="xm-select-demo"></div>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
</body>
</html>
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('authCase')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(role)', function(data){
            if(data.value == 3){
                $('#shejishi').removeClass('hidden');
            }else{
                $('#shejishi').addClass('hidden');
            }
        });
        form.on('select(role2)', function(data){
            if(data.value == 3){
                $('#shejishi2').removeClass('hidden');
            }else{
                $('#shejishi2').addClass('hidden');
            }
        });
        form.on('select(role5)', function(data){
            if(data.value == 3){
                $('#anli').removeClass('hidden');
            }else{
                $('#anli').addClass('hidden');
            }
        });
    });
    var demo1 = xmSelect.render({
        el: '#demo1',
        autoRow: true,
        name: 'user_sps',
        cascader: {
            show: true,
            indent: 200,
        },
        data(){
            return {$province}
        }
    })
    var demo2 = xmSelect.render({
        el: '#demo2',
        autoRow: true,
        name: 'user_d_auth_sids',
        cascader: {
            show: true,
            indent: 200,
        },
        data(){
            return {$province_s}
        }
    })
</script>